/*-----------------------------------------------------------------------------
 * file:  sr_ip.h 
 * date:  Thu Oct 18, 2012  
 * Author: yujiali@cs.toronto.edu
 *
 * Description:
 *
 * Methods and datastructures for handeling the ARP packets 
 *---------------------------------------------------------------------------*/

#ifndef sr_IP_H
#define sr_IP_H

#include <sys/types.h>

struct sr_instance;

int sr_handle_ip(struct sr_instance*, uint8_t*, unsigned int, char*);

int sr_send_ip_packet(struct sr_instance* sr, uint32_t ip_src, uint32_t ip_dst,
        uint8_t prot, uint8_t tos, uint8_t ttl, uint8_t* buf, unsigned int len,
        uint16_t id, uint8_t df, uint8_t* opt, unsigned int opt_len);

int sr_send_ip_pkt_w_hdr(struct sr_instance* sr, struct ip* ip_hdr, 
        uint8_t* buf, unsigned int len);

int sr_send_ip_to_ethernet_thread_safe(struct sr_instance* sr, uint8_t* buf);

uint16_t sr_checksum(uint16_t* buf, unsigned int count, unsigned int pad);

void sr_print_iphdr(struct ip* ip_hdr);

#define CHECKSUM_PAD        1
#define CHECKSUM_DONT_PAD   0



#endif /* -- sr_IP_H -- */

